import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import postCssPxToRem from "postcss-pxtorem";
// https://vite.dev/config/
export default defineConfig({
  alias: {
    "@": path.resolve(__dirname, "src"),
    "@api": path.resolve(__dirname, "src/api"), // 为./src配置别名  // 为./src配置别名
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 192, // 换算的基数
          propList: ["*"], // 可以从px更改为rem的属性
        }),
      ],
    },
  },
  plugins: [vue()],
  server: {
    port: 8088,
    host: true,
    open: true,
    proxy: {
      // https://cn.vitejs.dev/config/#server-proxy
      "/dev-api": {
        target: "http://localhost:3002/v1.0/api/",
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/dev-api/, ""),
      },
      "/dev-student": {
        target: "http://62.234.30.177",
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/dev-student/, ""),
      },
      "/api-node": {
        target: "http://localhost:3000",
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/api-node/, ""),
      },
    },
  },
});
